﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AsyncCamera.Camera.Structure;
using System.Windows.Threading;
using System.Threading;
using Incendios0_1.Camera;
using Incendios0_1.Camera.media;
using Incendios0_1.tools;
using Incendios0_1.Camera.wpfdatamanager;

namespace AsyncCamera.Camera.media
{
    public abstract class MediaElement
    {
        protected Guid id;
        public Guid GUID
        {
            get { return this.id; }
        }

        protected MediaState currentState;
        public MediaState CurrentState
        {
            get { return currentState;}
        }
        protected DispatcherTimer metronome;
        protected double fps;
        public double FPS
        {
            get { return this.fps; }
            set
            {
                if (currentState == MediaState.Stop || currentState == MediaState.Pause)
                {
                    this.fps = value;
                }
            }
        }

        private AbstractCamera attachedCamera;
        public AbstractCamera AttachedCamera
        {
            get { return this.attachedCamera; }
            set
            {
                this.attachedCamera = value;
            }
        } 

        public MediaElement()
        {
            currentState = MediaState.Stop;
            id = System.Guid.NewGuid();
        }

        protected void checkForState(MediaState check)
        {
            if (this.currentState != check)
                throw new MediaException("The current state is different from the checked");
        }

        protected abstract void Initialize();
        public abstract void Start();
        public abstract void Stop();
        public abstract void Pause();
        protected abstract void Tick(object sender, EventArgs e);
    }
}
